/*
 *
 *
 *
 *
 */


#ifndef __H_REDIS_CONN_H__
#define __H_REDIS_CONN_H__


#include "hiredis/hiredis.h"

typedef struct _redis_conn_ctx {
    redisContext *c;
} redis_conn_ctx;

typedef struct _redis_conn_result {
    int type;
    int array_count;

    union {
#define REDIST_CONN_RESULT_ST_SUCCESS 0
#define REDIST_CONN_RESULT_ST_FAILED -1
        int status;
        int l;
        char *str;
        struct _redis_conn_result *array;
    } r;

} redis_conn_result;


redis_conn_ctx *redisconn_connect(char *ip, unsigned short port);
void redisconn_close(redis_conn_ctx *ctx);

void redisconn_free_result(redis_conn_result *result);
redis_conn_result *redisconn_run_command(redis_conn_ctx *c, char *cmd, int cmd_len);
redis_conn_result *redisconn_get_subscribe(redis_conn_ctx *c);


void redisconn_print_result(redis_conn_result *result);


#endif
